resources.c
libgtkinspector_la_SOURCES = \
+ actions.h \
+ actions.c \
button-path.h \
button-path.c \
classes-list.h \
$(LDFLAGS)
templates = \
+ actions.ui \
button-path.ui \
classes-list.ui \
css-editor.ui \
--- /dev/null
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+#include "actions.h"
+#include "gtkwidgetprivate.h"
+
+enum
+{
+ COLUMN_PREFIX,
+ COLUMN_NAME,
+ COLUMN_ENABLED,
+ COLUMN_PARAMETER,
+ COLUMN_STATE
+};
+
+struct _GtkInspectorActionsPrivate
+{
+ GtkListStore *model;
+ GtkWidget *prefix_label;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorActions, gtk_inspector_actions, GTK_TYPE_BOX)
+
+static void
+gtk_inspector_actions_init (GtkInspectorActions *sl)
+{
+ sl->priv = gtk_inspector_actions_get_instance_private (sl);
+ gtk_widget_init_template (GTK_WIDGET (sl));
+}
+
+static void
+add_actions (GtkInspectorActions *sl,
+ const gchar *prefix,
+ GActionGroup *group)
+{
+ GtkTreeIter iter;
+ gint i;
+ gchar **names;
+ gboolean enabled;
+ const gchar *parameter;
+ GVariant *state;
+ gchar *state_string;
+
+ gtk_widget_show (GTK_WIDGET (sl));
+
+ names = g_action_group_list_actions (group);
+ for (i = 0; names[i]; i++)
+ {
+ enabled = g_action_group_get_action_enabled (group, names[i]);
+ parameter = (const gchar *)g_action_group_get_action_parameter_type (group, names[i]);
+ state = g_action_group_get_action_state (group, names[i]);
+ if (state)
+ state_string = g_variant_print (state, FALSE);
+ else
+ state_string = g_strdup ("");
+ gtk_list_store_append (sl->priv->model, &iter);
+ gtk_list_store_set (sl->priv->model, &iter,
+ COLUMN_PREFIX, prefix,
+ COLUMN_NAME, names[i],
+ COLUMN_ENABLED, enabled,
+ COLUMN_PARAMETER, parameter,
+ COLUMN_STATE, state_string,
+ -1);
+ g_free (state_string);
+ }
+ g_strfreev (names);
+}
+
+void
+gtk_inspector_actions_set_object (GtkInspectorActions *sl,
+ GObject *object)
+{
+ gtk_list_store_clear (sl->priv->model);
+ gtk_widget_hide (GTK_WIDGET (sl));
+
+ if (GTK_IS_APPLICATION (object))
+ add_actions (sl, "app", G_ACTION_GROUP (object));
+ else if (GTK_IS_APPLICATION_WINDOW (object))
+ add_actions (sl, "win", G_ACTION_GROUP (object));
+ else if (GTK_IS_WIDGET (object))
+ {
+ gchar **prefixes;
+ GActionGroup *group;
+ gint i;
+
+ prefixes = _gtk_widget_list_action_prefixes (GTK_WIDGET (object));
+ if (prefixes)
+ {
+ for (i = 0; prefixes[i]; i++)
+ {
+ group = _gtk_widget_get_action_group (GTK_WIDGET (object), prefixes[i]);
+ add_actions (sl, prefixes[i], group);
+ }
+ g_free (prefixes);
+ }
+ }
+}
+
+static void
+gtk_inspector_actions_class_init (GtkInspectorActionsClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/actions.ui");
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, model);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, prefix_label);
+}
+
+GtkWidget *
+gtk_inspector_actions_new (void)
+{
+ return GTK_WIDGET (g_object_new (GTK_TYPE_INSPECTOR_ACTIONS, NULL));
+}
+
+// vim: set et sw=2 ts=2:
--- /dev/null
+/*
+ * Copyright (c) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GTK_INSPECTOR_ACTIONS_H_
+#define _GTK_INSPECTOR_ACTIONS_H_
+
+#include <gtk/gtk.h>
+
+#define GTK_TYPE_INSPECTOR_ACTIONS (gtk_inspector_actions_get_type())
+#define GTK_INSPECTOR_ACTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_ACTIONS, GtkInspectorActions))
+#define GTK_INSPECTOR_ACTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_ACTIONS, GtkInspectorActionsClass))
+#define GTK_INSPECTOR_IS_ACTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_ACTIONS))
+#define GTK_INSPECTOR_IS_ACTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_ACTIONS))
+#define GTK_INSPECTOR_ACTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_ACTIONS, GtkInspectorActionsClass))
+
+
+typedef struct _GtkInspectorActionsPrivate GtkInspectorActionsPrivate;
+
+typedef struct _GtkInspectorActions
+{
+ GtkBox parent;
+ GtkInspectorActionsPrivate *priv;
+} GtkInspectorActions;
+
+typedef struct _GtkInspectorActionsClass
+{
+ GtkBoxClass parent;
+} GtkInspectorActionsClass;
+
+G_BEGIN_DECLS
+
+GType gtk_inspector_actions_get_type (void);
+GtkWidget *gtk_inspector_actions_new (void);
+void gtk_inspector_actions_set_object (GtkInspectorActions *sl,
+ GObject *object);
+
+G_END_DECLS
+
+#endif // _GTK_INSPECTOR_ACTIONS_H_
+
+// vim: set et sw=2 ts=2:
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="gtk30">
+ <object class="GtkListStore" id="model">
+ <columns>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gboolean"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <template class="GtkInspectorActions" parent="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="prefix_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="margin">20</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="expand">True</property>
+ <property name="hscrollbar-policy">automatic</property>
+ <property name="vscrollbar-policy">always</property>
+ <property name="shadow-type">in</property>
+ <child>
+ <object class= "GtkTreeView">
+ <property name="visible">True</property>
+ <property name="model">model</property>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Prefix</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="scale">0.8</property>
+ </object>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Name</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="scale">0.8</property>
+ </object>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Enabled</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="scale">0.8</property>
+ </object>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">Parameter Type</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="scale">0.8</property>
+ </object>
+ <attributes>
+ <attribute name="text">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn">
+ <property name="title" translatable="yes">State</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="scale">0.8</property>
+ </object>
+ <attributes>
+ <attribute name="text">4</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
*/
#include <glib.h>
+#include "actions.h"
#include "button-path.h"
#include "classes-list.h"
#include "css-editor.h"
gtk_inspector_register_resource ();
+ g_type_ensure (GTK_TYPE_INSPECTOR_ACTIONS);
g_type_ensure (GTK_TYPE_INSPECTOR_BUTTON_PATH);
g_type_ensure (GTK_TYPE_INSPECTOR_CLASSES_LIST);
g_type_ensure (GTK_TYPE_INSPECTOR_CSS_EDITOR);
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/inspector">
+ <file>actions.ui</file>
<file>button-path.ui</file>
<file>classes-list.ui</file>
<file>css-editor.ui</file>
#include "data-list.h"
#include "themes.h"
#include "signals-list.h"
+#include "actions.h"
+
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
gtk_inspector_classes_list_set_object (GTK_INSPECTOR_CLASSES_LIST (iw->classes_list), selected);
gtk_inspector_css_editor_set_object (GTK_INSPECTOR_CSS_EDITOR (iw->widget_css_editor), selected);
gtk_inspector_data_list_set_object (GTK_INSPECTOR_DATA_LIST (iw->data_list), selected);
+ gtk_inspector_actions_set_object (GTK_INSPECTOR_ACTIONS (iw->actions), selected);
if (GTK_IS_WIDGET (selected))
gtk_inspector_flash_widget (iw, GTK_WIDGET (selected));
}
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, python_shell);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_popup);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, data_list);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, actions);
gtk_widget_class_bind_template_callback (widget_class, on_inspect);
gtk_widget_class_bind_template_callback (widget_class, on_widget_tree_selection_changed);
GtkWidget *widget_css_editor;
GtkWidget *object_hierarchy;
GtkWidget *data_list;
+ GtkWidget *actions;
GtkWidget *widget_popup;
<property name="label" translatable="yes">Data</property>
</object>
</child>
+ <child>
+ <object class="GtkInspectorActions" id="actions">
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Actions</property>
+ </object>
+ </child>
</object>
<packing>
<property name="resize">True</property>
gtk/gtkvolumebutton.c
gtk/gtkwidget.c
gtk/gtkwindow.c
+gtk/inspector/actions.ui.h
gtk/inspector/button-path.ui.h
gtk/inspector/classes-list.c
gtk/inspector/classes-list.ui.h